/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine - graphics/context
// Copyright (c) 2015.  All Rights Reserved
//
// File:		AEMainContext.cpp
// Author:		Gianluca Belardelli
// Date:		20/01/2015
//
/////////////////////////////////////////////////////////////////////////
#include "AEEngine.h"
#include "graphics/context/AEMainContext.h"

#if defined AE_PLATFORM_WIN32
	#include "application/AEWindow_win32.h"
	#if defined AE_OPENGL
		#define DEFAULT_NAME		"OGLMainCtx_win32"
	#else
		#define DEFAULT_NAME		"MainCtx_win32"
	#endif
#elif defined AE_PLATFORM_ANDROID
	#include "application/AEWindow_android.h"
	#if defined AE_OPENGLES
		#define DEFAULT_NAME		"ESMainCtx_android"
	#elif defined AE_OPENGLES2
		#define DEFAULT_NAME		"ES2MainCtx_android"
	#elif defined AE_OPENGLES3
		#define DEFAULT_NAME		"ES3MainCtx_android"
	#endif
#endif

#define DEFAULT_PRIORITY	1000.0f

AEMainContext::AEMainContext( void ) : AERenderContext()
{
	m_bRendersIntoBackBuffer = AETRUE;
	SetContextName( DEFAULT_NAME );
	m_spViewProps = new ( AEngine::GetMemManager()->GetStack().BlockAlloc( sizeof(AEContextViewProperties) ) ) AEContextViewProperties();

	m_spViewProps->SetClipPlanes( 0.1f, 100.0f );
	m_spViewProps->SetDisplayAspectRatio( AEngine::GetDefaultVideoConfig()->GetDisplayAspectRatio() );
	m_spViewProps->SetFov( 0.0f, 45.0f );
	m_spViewProps->SetProjectionType( AEPROJECTIONTYPE_PERSPECTIVE );
	//m_spViewProps->SetProjectionType( AEProjectionType::AEPROJECTIONTYPE_ORTHOGRAPHIC );
	m_spViewProps->SetOrthographicSize( AEngine::GetDefaultVideoConfig()->GetVideoMode().uiXRes, AEngine::GetDefaultVideoConfig()->GetVideoMode().uiYRes );

	AEMatrix4f matLookAt;
	matLookAt.SetIdentity();
	matLookAt.SetLookAtMatrix( AEVector4f( 3.0, 3.0f, 4.0f ), AEVector4f( 0.0, 0.0, 0.0 ), AEVector4f( 0.0, 1.0, 0.0 ) );

	m_lpContextCamera = new AECamera();
	m_lpContextCamera->Set( matLookAt );
}

AEMainContext::~AEMainContext( void )
{
}
